
<template>
	<!-- 添加弹框 -->
	<el-dialog title="" visible :show-close="false" :modal-append-to-body="false" size="tiny" class="wrap">
		<i class="el-icon-close close" @click="cancel" style="color: white;z-index: 99;"></i>
	    <div class="bt">分校老师新增管理</div>
	    <el-form label-width="100px" class="form">
	  	<!-- <el-form-item label="工号">
 				<el-input v-model="vgh"  placeholder="请输入老师工号" class="select-block"></el-input>
 			</el-form-item> -->
			<el-form-item label="工号">
					<el-select v-model="vgh" placeholder="请选择..." class="select-block">
						<el-option :label="v.mc" :value="v.id" v-for="v in ghList"></el-option>
					</el-select>
			</el-form-item>
 			<el-form-item label="中文名">
 				<el-input v-model="vzwm"  placeholder="请输入中文名" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="英文名">
 				<el-input v-model="vywm"  placeholder="请输入英文名" class="select-block"></el-input>
 			</el-form-item>
			<el-form-item label="行政老师">
					<el-select v-model="xzls" placeholder="请选择行政老师" class="select-block">
						<el-option :label="v.xslsmc" :value="v.xzlsid+''" v-for="v in xzlsList"></el-option>
					</el-select>
			</el-form-item>
			<el-form-item label="性别">
                   <el-select v-model="vxb" placeholder="请选择性别"  class="select-block" >
  					  <el-option label="男" value="男"></el-option>
  					  <el-option label="女" value="女" ></el-option>
  			      </el-select>
 			</el-form-item>
 			<el-form-item label="密码">
 				<el-input v-model="vmm"  placeholder="请输入密码" class="select-block"></el-input>
 			</el-form-item>
		    <el-form-item label="电话">
 				<el-input v-model="vdh"  placeholder="请输入电话" class="select-block"></el-input>
 		    </el-form-item>
		<!--<el-form-item label="头像">
 				<el-input v-model="vtx"  placeholder="请选择头像" class="select-block"></el-input>
 		</el-form-item>-->

        <!--<el-form-item label="班级数">
 				<el-input v-model="vbjs"  placeholder="请输入班级数" class="select-block"></el-input>
 			</el-form-item>-->
        <el-form-item label="类型">
                   <el-select v-model="vlstype" placeholder="请选择类型"  class="select-block" >
  					  <el-option label="老师" value="ls"></el-option>
  					  <el-option label="行政" value="xz" ></el-option>
							<el-option label="行政主任" value="xzz" ></el-option>
  					  <el-option label="财务" value="cw" ></el-option>
  					  <el-option label="财务主任" value="cwz" ></el-option>
							<el-option label="教务主任" value="lsz" ></el-option>
  					   <el-option label="校长" value="cap" ></el-option>
  			      </el-select>
 			</el-form-item>
		</el-form>

		<el-button type="info" class="submit" @click="submit">保存</el-button>
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	export default {
		data() {
			return {
				vgh: '',
				vmm: '',
				vdh: '',
//				vtx: '',
				vxb: '',
				vzwm: '',
				vywm: '',
//				vbjs: '',
				vlstype: '',
				xzls:'',
				ghList:'',
				xzlsList: []
			}
		},
		created() {
			this.getxzlsList();
			this.getghList();
		},
		methods: {
			getghList () {
				var logininfo = JSON.parse(localStorage.logininfo);
					this.axios.get( this.$store.state.api + 'ls/gh', {
							params: {
								// yhid: logininfo.id,
								xxid:logininfo.xxid
							}
					})
					.then( res => {
							console.log('1111',res)
							this.ghList = res.data.data.list;
					}).catch( res => {
							console.log(res)
					})
			},
			getxzlsList () {
				var logininfo = JSON.parse(localStorage.logininfo);
					this.axios.get( this.$store.state.api + 'ls/xzxzls', {
							params: {
								yhid: logininfo.id,
								xxid:logininfo.xxid
							}
					})
					.then( res => {
							console.log(res)
							this.xzlsList = res.data.data;
					}).catch( res => {
							console.log(res)
					})
			},
			submit() {
				//检测
				this.$store.state.loading = true;
			    if(!this.vgh) {
					this.$message.warning('请填写工号');
					this.$store.state.loading = false;
					return;
				}
				else if(!this.vmm) {
					this.$message.warning('请填写密码');
					this.$store.state.loading = false;
					return;
				}
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					xzid:this.xzls,
					gh: this.vgh,
					mm: this.vmm,
					dh: this.vdh,
		//			tx: this.vtx,
					xb: this.vxb,
					zwm: this.vzwm,
					ywm: this.vywm,
//					bjs: this.vbjs,
					lstype: this.vlstype,
					yhid:logininfo.id,
					xxid:logininfo.xxid
				});
				//执行
				this.axios.post(this.$store.state.api + 'ls/insert', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						} else {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.warning("服务器繁忙，请重试");
						//this.$emit('close', { type: 'add', cancel: false });
						this.$store.state.loading = false;
					})
			},
			cancel() {
				this.$emit('close', { type: 'add', cancel: true })
			}
		}
	}
</script>
<style lang="less" scoped>
	.wrap {
		.el-dialog--small{
			width: 200px;
		}
		.bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top:0;
			left:0;
			background: #50BFFF;
			margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
	     .select-block {
 		display: block;
 			width: 85%;
 	}
	.form {
		text-align: center;
		margin-top:20px;

	}
	.input {
		display: inline-block;
		}
		.input-block {
			margin-bottom: 20px;
			text-align: center;
			.input {
				width: 180px;
				display: inline-block;
			}

		}
	     .select-block {
 		display: block;
 			width: 85%;
 	}
	.form {
		text-align: center;
		margin-top:20px;

	}
	.input {
		display: inline-block;

			}
		.submit {
			width: 120px;
			display: block;
			margin: 0 auto;
			margin-top: 20px;
		}

	}
</style>
